#ifndef	__AURORA_SPRITE_H__
#define	__AURORA_SPRITE_H__

#include"StringHelper.h"

/**
	Record size of Frame
*/
struct FRect
{
	int _left,_top,_right,_down;

	FRect()
	{
		_left = _top = _right = _down = 0;
	}
	FRect(int left,int top,int right,int down)
	{
		_left = left;
		_top = top;
		_right = right;
		_down = down;
	}
	
	FRect(const FRect& rhs)
	{
		_left = rhs._left;
		_top = rhs._top;
		_right = rhs._right;
		_down = rhs._down;
	}

	FRect& operator = (const FRect& rhs)
	{
		_left = rhs._left;
		_top = rhs._top;
		_right = rhs._right;
		_down = rhs._down;
		return *this;
	}
};

/**
	Module in Module Editor
*/
struct SpriteModule
{
	string _moduleId;
	int _u,_v;
	int _width,_height;
};

/**
	Module in Frame
*/
struct SpriteFModule
{
	string _moduleId;
	int _ox,_oy;
};

/**
	Frame in Frame Editor
*/
struct SpriteFrame
{
	string _frameId;
	vector<SpriteFModule> _allFModules;
	FRect _frameRect;
	int _frameWidth,_frameHeight;

	SpriteFrame()
	{
		_frameWidth = 0;
		_frameHeight = 0;
	}
};


/**
	Frame in Animation
*/
struct SpriteAFrame
{
	string _frameId;
	int _time;
	int _ox,_oy;
};


/**
	Anim in Animation Editor
*/
struct SpriteAnim
{
	string _animId;
	vector<SpriteAFrame> _allAFrames;
};


class AuroraSprite
{
protected:
	FILE *_fp;

public:
	int _width,_height;
	vector<SpriteModule> _allModules;
	vector<SpriteFrame> _allFrames;
	vector<SpriteAnim> _allAnims;

private:
	SpriteModule GetModuleByModuleId(string moduleId);

	/**
		After LoadAuroraSprite(), we sum per frame's rect and size.
	*/
	void InitFrameRect();

public:
	AuroraSprite();
	~AuroraSprite();

	void LoadAuroraSprite(char* filename);
	void LookFileContent() const;
};

#endif	//	__AURORA_SPRITE_H__